# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Llewelyn Trahaearn <WoefulDerelict at GMail dot com>
# Contributor: Maxime Gauduin <alucryd at archlinux dot org>
# Contributor: FadeMind <fademind at gmail dot com>
# Contributor: Balló György <ballogyor+arch at gmail dot com>
# Contributor: Branchini Massimo <max.bra.gtalk at gmail dot com

pkgbase=libdbusmenu
pkgname=("${pkgbase}-glib" "${pkgbase}-gtk"{2,3})
_bzrtag=16.04.0
_bzrrev=498
pkgver=${_bzrtag}.r${_bzrrev}
pkgrel=2
pkgdesc='Library for passing menus over DBus'
url='https://launchpad.net/libdbusmenu'
arch=('loong64' 'x86_64')
license=('GPL3' 'LGPL2.1' 'LGPL3')
makedepends=('breezy' 'gnome-common' 'gobject-introspection' 'gtk2' 'gtk3' 'intltool' 'vala')
options=('!emptydirs')
source=($pkgbase::bzr+https://code.launchpad.net/~dbusmenu-team/libdbusmenu/trunk.16.10#revision=$_bzrrev)
sha512sums=('SKIP')
validpgpkeys=('45B1103FB93ACBD90296DBCAE83D089481836EBF')  # Marco Trevisan (at 3v1n0.net) <marco.trevisan@3v1n0.net>

prepare() {
  (cd ${pkgbase}
    NOCONFIGURE=1 ./autogen.sh
  )
  cp -ra ${pkgbase}{,-gtk2}
}

build() {
  msg2 "Building gtk3..."
  (cd ${pkgbase}
    ./configure --prefix=/usr \
      --sysconfdir=/etc \
      --localstatedir=/var \
      --with-gtk=3 \
      --enable-gtk-doc
    sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
    make
  )

  msg2 "Building gtk2..."
  (cd ${pkgbase}-gtk2
    ./configure --prefix=/usr \
      --sysconfdir=/etc \
      --localstatedir=/var \
      --with-gtk=2
    sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
    make
  )
}

package_libdbusmenu-glib() {
  depends=('glib2')

  cd ${pkgbase}
  make -j1 -C libdbusmenu-glib DESTDIR="${pkgdir}" install
  make -j1 -C docs/libdbusmenu-glib DESTDIR="${pkgdir}" install
}

package_libdbusmenu-gtk2() {
  pkgdesc+=" (GTK+ 2 library)"
  depends=("${pkgbase}-glib" 'gtk2')

  cd ${pkgbase}-gtk2
  make -j1 -C libdbusmenu-glib DESTDIR="${pkgdir}" install
  make -j1 -C libdbusmenu-gtk DESTDIR="${pkgdir}" install
  make -j1 -C libdbusmenu-glib DESTDIR="${pkgdir}" uninstall
}

package_libdbusmenu-gtk3() {
  pkgdesc+=" (GTK+ 3 library)"
  depends=("${pkgbase}-glib" 'gtk3')

  cd ${pkgbase}
  make -j1 -C libdbusmenu-glib DESTDIR="${pkgdir}" install
  make -j1 -C libdbusmenu-gtk DESTDIR="${pkgdir}" install
  make -j1 -C libdbusmenu-glib DESTDIR="${pkgdir}" uninstall
  make -j1 -C docs/libdbusmenu-gtk DESTDIR="${pkgdir}" install
}

# vim: ts=2 sw=2 et:
